package com.example.common.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.common.mapper.EmployeesMapper;
import com.example.common.pojo.Employees;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/employee")
public class EmployeesController {

    @Autowired
    private EmployeesMapper employeesMapper;

    @RequestMapping(value = "/test",produces = {"application/json"})
    public String test(@RequestParam(value = "id",defaultValue = "ssssss") String str){
        return str;
    }

    @RequestMapping(value = "/t1")
    public List<Employees> getList(@RequestBody Employees employees){
        System.out.println(employees);
        QueryWrapper<Employees> wrapper = new QueryWrapper<>();
        wrapper.lambda().apply("date_format(birth_date,'Y%-m%-d%')={0}","1961-05-02");
        wrapper.lambda().eq(Employees::getGender,employees.getGender());
        List<Employees> employees1 = employeesMapper.selectList(wrapper);
        return employees1;
    }


}
